//
//  BoutiqueDetailPageVC.m
//  NewNest
//
//  Created by hesiyao on 16/1/17.
//  Copyright © 2016年 www.lanou3g.com蓝鸥科技. All rights reserved.
//

#import "BoutiqueDetailPageVC.h"
#import "CarouselView.h"
#import "BoutiqueDetailPageView.h"
#import <UIImageView+WebCache.h>
@interface BoutiqueDetailPageVC ()
@property (nonatomic, retain) UIScrollView *scrollview;
@property (nonatomic, retain) NSMutableArray *imgArr;
@end

@implementation BoutiqueDetailPageVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 视图创建
    [self createSubviews];
    

    
}

/// 视图创建
- (void)createSubviews
{
    // 图片数组
    self.imgArr = _modal.imageUrl;
    //scrollview
    self.scrollview = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    self.scrollview.contentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height / 3 * (_imgArr.count + 1) );
    [self.view addSubview:_scrollview];
    
    // 上方的文章标题
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height / 10)];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.text = _modal.name;
    titleLabel.font = [UIFont systemFontOfSize:20];
    [self.scrollview addSubview:titleLabel];
    [titleLabel release];
    
    // 房屋类型视图
    BoutiqueDetailPageView *houseTypeView = [[BoutiqueDetailPageView alloc] initWithFrame:CGRectMake(10, titleLabel.frame.origin.y + titleLabel.frame.size.height + 10, (self.view.frame.size.width - 20) / 4 , self.view.frame.size.height / 6)];
    houseTypeView.titleLabel.text = _modal.houseType;
    houseTypeView.imgview.image = [UIImage imageNamed:@"C30.jpg"];
//    houseTypeView.backgroundColor = [UIColor redColor];
    [self.scrollview addSubview:houseTypeView];
    [houseTypeView release];
    
    BoutiqueDetailPageView *styleView = [[BoutiqueDetailPageView alloc] initWithFrame:CGRectMake(houseTypeView.frame.origin.x + houseTypeView.frame.size.width , houseTypeView.frame.origin.y, houseTypeView.frame.size.width, houseTypeView.frame.size.height)];
    styleView.titleLabel.text = _modal.style;
    styleView.imgview.image = [UIImage imageNamed:@"C20.jpg"];
    [self.scrollview addSubview:styleView];
    [styleView release];
    
    BoutiqueDetailPageView *spaceView = [[BoutiqueDetailPageView alloc] initWithFrame:CGRectMake(styleView.frame.origin.x + styleView.frame.size.width, houseTypeView.frame.origin.y, houseTypeView.frame.size.width, houseTypeView.frame.size.height)];
    spaceView.titleLabel.text = _modal.space;
    spaceView.imgview.image = [UIImage imageNamed:@"C22"];
    [self.scrollview addSubview:spaceView];
    [spaceView release];
    
    BoutiqueDetailPageView *priceView = [[BoutiqueDetailPageView alloc] initWithFrame:CGRectMake(spaceView.frame.origin.x + spaceView.frame.size.width, houseTypeView.frame.origin.y, houseTypeView.frame.size.width, houseTypeView.frame.size.height)];
    priceView.titleLabel.text = _modal.price;
    priceView.imgview.image = [UIImage imageNamed:@"C21"];
    [self.scrollview addSubview:priceView];
    [priceView release];
    
    // 用于存放所有图片的数组
    
    for (NSInteger i = 0; i < _imgArr.count; i++) {
        UIImageView *imgview = [[UIImageView alloc] initWithFrame:CGRectMake(10, self.view.frame.size.height / 3 * (i + 1) + 10, self.view.frame.size.width - 20, self.view.frame.size.height / 3)];
        imgview.layer.cornerRadius = 5;
        imgview.clipsToBounds = YES;
        [imgview sd_setImageWithURL:[NSURL URLWithString:_imgArr[i]]];
        [self.scrollview addSubview:imgview];
        [imgview release];
    }
    
    // 右上角的喜欢按钮
    UIButton *likeBtton = [UIButton buttonWithType:UIButtonTypeCustom];
    likeBtton.frame = CGRectMake(0, 0, 25, 25);
    [likeBtton setImage:[UIImage imageNamed:@"kongaixin@2x"] forState:UIControlStateNormal];
    [likeBtton setImage:[UIImage imageNamed:@"hongaixin@2x"] forState:UIControlStateSelected];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:likeBtton];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
